<?php
header("Content-type: text/html; charset=utf-8");
$conn = @mysql_connect( 'localhost','root','')
or die('数据库无法连接！');
mysql_set_charset('utf8');
@mysql_select_db('neu-video',$conn)
or die('数据库无法连接');
$sql ='select * from comments';
$result = mysql_query($sql,$conn);
$users=fetch_array($result);
echo'<table border="1">';
echo '<caption>电影评论表</caption>';
echo'<tr>
<th>评论ID</th>
<th>评论内容</th>
<th>评论日期</th>
<th>评论用户</th>
<th>评论视频</th>
</tr>';
foreach ($users as $one) {
echo'<tr>';
echo '<td>'.$one['cid'].'<br>'.'</td>';
echo '<td>'.$one['content'].'<br>'.'</td>';
echo '<td>'.$one['cdate'].'<br>'.'</td>';
echo '<td>'.$one['uid'].'<br>'.'</td>';
echo '<td>'.$one['vid'].'<br>'.'</td>';
echo'</tr>';
}

function fetch_array($Results){
$arrs =array();
while ($Results && ($row = mysql_fetch_assoc($Results))!== FALSE)
{$arrs[]=$row;}
return $arrs;
}
 ?>
